# config  n. 配置，布局; 显示配置信息命令
import logging

from redis import StrictRedis

"""项目的配置"""


class Config(object):
    DEBUG = True
    # 加密
    """获取随机加密的编码步骤:
    import os 
    os.urandom(48)
    import base64
    base64.b64encode(os.urandom(48))
    """
    SECRET_KEY = 'dKxs1Hvknez50ofBAqk86RoU31Z8n/25fR2XQB0bOmRvO6Bs3pEWGnRZSjHr8vkj'
    # 为数据添加配置
    SQLALCHEMY_DATABASE_URI = 'mysql://root:mysql@127.0.0.1:3306/wanshang'
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True

    # Redis 的配置
    REDIS_HOST = '127.0.0.1'
    REDIS_PORT = 6379

    # Session保存位置
    SESSION_TYPE = 'redis'
    # 开启 session 签名
    SESSION_USE_SIGNER = True
    # 指定Session 保存的redis
    SESSION_REDIS = StrictRedis(host=REDIS_HOST, port=REDIS_PORT)
    # 设置需要过期
    SESSION_PERMANENT = False
    # 设置过期时间
    PERMANENT_SESSION_LIFETIME = 86400 * 2

    # 设置日志等级
    LOG_LEVEL = logging.DEBUG


class DevelopmentCfing(Config):
    """开发环境下的配置"""
    DEBUG = True


class ProductionConfig(Config):
    """生产环境下的配置"""
    DEBUG = False
    LOG_LEVEL = logging.WARNING


class TestingConfig(Config):
    """单元测试环境下的配置"""
    DEBUG = True
    TESTING = True


config = {

    "development": DevelopmentCfing,
    "production": ProductionConfig,
    "testing": TestingConfig

}


